#define _CRT_SECURE_NO_WARNINGS 1
#include"Queue.h"
typedef int BTDataType;
typedef struct BinaryTreeNode
{
	BTDataType _data;
	struct BinaryTreeNode* _left;
	struct BinaryTreeNode* _right;
}BTNode;



BTNode* BuyNode(BTDataType x)
{
	BTNode* root=malloc(sizeof(BTNode));
	root->_data = x;
	root->_left = root->_right = NULL;
	return root;
}
BTNode* CreatBinaryTree()
{
	BTNode* node1 = BuyNode(1);
	BTNode* node2 = BuyNode(2);
	BTNode* node3 = BuyNode(3);
	BTNode * node4 = BuyNode(4);
	BTNode* node5 = BuyNode(5);
	BTNode* node6 = BuyNode(6);
	node1->_left = node2;
	node1->_right = node4;
	node2->_left = node3;
	node4->_left = node5;
	node4->_right = node6;
	return node1;
}

void TreeLevelOrder(BTNode* root)
{
	Queue q;
	QueueInit(&q);
	QueuePush(&q, root);
	while (!QueueEmpty(&q))
	{
		BTNode* front = QueueFront(&q);
		QueuePop(&q);
		if (front == NULL)
		{
			printf("#");
		}
		else
		{
			printf("%d", front->_data);
			QueuePush(&q, front->_left);
			QueuePush(&q, front->_right);
		}
	}
	QueueDestroy(&q);
}
int main()
{
	BTNode* root=CreatBinaryTree();
	TreeLevelOrder(root);
	return 0;
}
